<?php

namespace App\Repositories\Config;


use App\Models\GameTool\GameRechargeItem;
use App\Repositories\BaseRepository;

class GameRechargeItemRepository extends BaseRepository
{

    public function __construct(GameRechargeItem $model)
    {
        $this->model = $model;
    }

    public function create(array $params)
    {
        return GameRechargeItem::create($params);
    }

    public function getByCondition($condition)
    {
        $query = GameRechargeItem::query();

        if (isset($condition['game_id'])) {
            $query->where('game_id', '=', $condition['game_id']);
        }

        $items = $query->orderBy('id', 'DESC')->get()->pluck('item_name','item_id')->toArray();
        return $items;
    }
}